package com.ruoyi.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.system.domain.SysCompanyType;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.SysCompanyClassification;
import com.ruoyi.system.service.ISysCompanyClassificationService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 企业规模Controller
 * 
 * @author ruoyi
 * @date 2024-08-14
 */
@RestController
@RequestMapping("/system/companyclassification")
public class SysCompanyClassificationController extends BaseController
{
    @Autowired
    private ISysCompanyClassificationService sysCompanyClassificationService;

    /**
     * 查询企业规模列表
     */
    @PreAuthorize("@ss.hasPermi('system:companyclassification:list')")
    @GetMapping("/list")
    public TableDataInfo list(SysCompanyClassification sysCompanyClassification)
    {
        startPage();
        List<SysCompanyClassification> list = sysCompanyClassificationService.selectSysCompanyClassificationList(sysCompanyClassification);
        return getDataTable(list);
    }

    /**
     * 查询企业规模列表
     */
    @PreAuthorize("@ss.hasPermi('system:companyclassification:lists')")
    @GetMapping("/lists")
    public AjaxResult lists(SysCompanyClassification sysCompanyClassification)
    {
        List<SysCompanyClassification> list = sysCompanyClassificationService.selectSysCompanyClassificationList(sysCompanyClassification);
        return success(list);
    }

    /**
     * 导出企业规模列表
     */
    @PreAuthorize("@ss.hasPermi('system:companyclassification:export')")
    @Log(title = "企业规模", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SysCompanyClassification sysCompanyClassification)
    {
        List<SysCompanyClassification> list = sysCompanyClassificationService.selectSysCompanyClassificationList(sysCompanyClassification);
        ExcelUtil<SysCompanyClassification> util = new ExcelUtil<SysCompanyClassification>(SysCompanyClassification.class);
        util.exportExcel(response, list, "企业规模数据");
    }

    /**
     * 获取企业规模详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:companyclassification:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Integer id)
    {
        return success(sysCompanyClassificationService.selectSysCompanyClassificationById(id));
    }

    /**
     * 新增企业规模
     */
    @PreAuthorize("@ss.hasPermi('system:companyclassification:add')")
    @Log(title = "企业规模", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SysCompanyClassification sysCompanyClassification)
    {
        return toAjax(sysCompanyClassificationService.insertSysCompanyClassification(sysCompanyClassification));
    }

    /**
     * 修改企业规模
     */
    @PreAuthorize("@ss.hasPermi('system:companyclassification:edit')")
    @Log(title = "企业规模", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SysCompanyClassification sysCompanyClassification)
    {
        return toAjax(sysCompanyClassificationService.updateSysCompanyClassification(sysCompanyClassification));
    }

    /**
     * 删除企业规模
     */
    @PreAuthorize("@ss.hasPermi('system:companyclassification:remove')")
    @Log(title = "企业规模", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Integer[] ids)
    {
        return toAjax(sysCompanyClassificationService.deleteSysCompanyClassificationByIds(ids));
    }

    /**
     * 状态修改
     */
    @PreAuthorize("@ss.hasPermi('system:companyclassification:edit')")
    @Log(title = "企业类型", businessType = BusinessType.UPDATE)
    @PutMapping("/changeStatus")
    public AjaxResult changeStatus(@RequestBody SysCompanyClassification sysCompanyClassification)
    {
        return toAjax(sysCompanyClassificationService.updateSysCompanyClassificationStatus(sysCompanyClassification));
    }
}
